package top.eggcode.modules.user.model;

import lombok.Data;
import top.eggcode.common.lang.BeanUnit;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Title:
 * Description: TODO
 * Date: 2021/5/10 9:24
 *
 * @author JiaQi Ding
 * @version 1.0
 */
@Data
public class PowerDTO {
    private String id;

    private String parentId;

    private String name;

    private String path;

    private String code;

    private Short type;

    private String icon;

    private Short sequence;

    private Short linkType;

    private List<PowerDTO> children;

    private LocalDateTime createdAt;

    /**
     * 构建视图模型
     */
    public static PowerDTO build(PowerEntity entity) {
        PowerDTO view = new PowerDTO();
        BeanUnit.copy(entity, view);
        return view;
    }

    /**
     * 转换业务模型
     */
    public PowerEntity convert() {
        PowerEntity power = new PowerEntity();
        BeanUnit.copy(this, power);
        return power;
    }

}
